<?php

/**
 * WithdrawModel 模型
 * Class WithdrawModel
 */
class WithdrawModel extends BaseModel
{

    public $tableName = "withdraw";
    public $errMsg = '';

    static private $_singleton;

    public function __construct()
    {
        parent::__construct($this->tableName);
    }

    static public function getSingleton()
    {
        if (!self::$_singleton) {
            self::$_singleton = new static();
        }

        return self::$_singleton;
    }

    static $statusText = [
        0   => '已申请',
        1   => '已打款',
        2   => '已拒绝'
    ];

    public function add($data)
    {
        try {
            $selfModel = static::getSingleton();
            return $selfModel->insert([
                'withdraw_no'   => $data['withdraw_no'],
                'user_id'       => $data['user_id'],
                'status'        => $data['status'],
                'point'         => $data['point'],
                'user_bank_id'  => $data['user_bank_id'],
                'create_time'   => time(),
            ]);
        } catch (Exception $e) {
            $this->errMsg = $e->getMessage();
            return false;
        }
    }


}